Option Strict Off
Option Explicit On
Friend Class achievements
	Inherits System.Windows.Forms.Form
	
	Dim unlock_codes(20) As String
	Dim titles(20) As String
	Dim subtitles(20) As String
	Dim secret(20) As Short
	Dim unlocked(20) As Short
	Dim num_achievements As Short
	
	Private Sub imgCheck_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles imgCheck.Click
		Dim Index As Short = imgCheck.GetIndex(eventSender)
		' do nothing
	End Sub
	
	Private Sub achievements_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		num_achievements = 11
		Call initialize()
		Dim i As Short
		For i = 0 To num_achievements - 1
			imgCheck(i).Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "/images/graphic_checkmark.jpg")
			imgCheck(i).SetBounds(imgCheck(0).Left, VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(imgCheck(0).Top) + 600 * i), 0, 0, Windows.Forms.BoundsSpecified.X Or Windows.Forms.BoundsSpecified.Y)
			lblTitle(i).Text = titles(i)
			lblTitle(i).SetBounds(lblTitle(0).Left, VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(lblTitle(0).Top) + 600 * i), 0, 0, Windows.Forms.BoundsSpecified.X Or Windows.Forms.BoundsSpecified.Y)
			lblSubtitle(i).Text = subtitles(i)
			lblSubtitle(i).Width = VB6.TwipsToPixelsX(3000)
			lblSubtitle(i).SetBounds(lblSubtitle(0).Left, VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(lblSubtitle(0).Top) + 600 * i), 0, 0, Windows.Forms.BoundsSpecified.X Or Windows.Forms.BoundsSpecified.Y)
			If unlocked(i) = 0 Then
				imgCheck(i).Visible = False
				If secret(i) Then
					lblSubtitle(i).Text = "?????????????"
				End If
			End If
		Next i
	End Sub
	
	Public Sub initialize()
		titles(0) = "Dominator"
		subtitles(0) = "Win 5 games in a row"
		unlock_codes(0) = "5in"
		
		titles(1) = "King of the World"
		subtitles(1) = "Collect 6 or more Provinces"
		unlock_codes(1) = "leo"
		
		titles(2) = "Tower of Terror"
		subtitles(2) = "Build a 60 card deck"
		unlock_codes(2) = "huge"
		
		titles(3) = "Monopoly"
		subtitles(3) = "Collect every copy of one card"
		unlock_codes(3) = "moneybags"
		
		titles(4) = "Slow Starter"
		subtitles(4) = "Skip your first 3 turns and still win"
		unlock_codes(4) = "turtle"
		
		titles(5) = "Die pig, die!"
		subtitles(5) = "Kill all your coppers"
		unlock_codes(5) = "murder"
		
		titles(6) = "Curses, foiled again!"
		subtitles(6) = "Buy 2 curses"
		unlock_codes(6) = "foiled"
		secret(6) = 1
		
		titles(7) = "The spice of life"
		subtitles(7) = "Buy 1 of everything"
		unlock_codes(7) = "variety"
		secret(7) = 1
		
		titles(8) = "Moneybags"
		subtitles(8) = "Buy no actions and still win"
		unlock_codes(8) = "chaching"
		secret(8) = 1
		
		titles(9) = "Attack of the clones"
		subtitles(9) = "Give every player the same name"
		unlock_codes(9) = "jeffjeffjeff"
		secret(9) = 1
		
		titles(10) = "Money hater"
		subtitles(10) = "Buy no coin cards and still win"
		unlock_codes(10) = "poorman"
		secret(10) = 1
		
		' read the file to see which is unlocked
		'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
		Dim str_Renamed As String
		str_Renamed = "test"
		FileOpen(1, My.Application.Info.DirectoryPath & "/achievements.txt", OpenMode.Append)
		FileClose(1)
		FileOpen(1, My.Application.Info.DirectoryPath & "/achievements.txt", OpenMode.Input)
		Dim i As Short
		Do While Not EOF(1)
			Input(1, str_Renamed)
			For i = 0 To num_achievements - 1
				'MsgBox "Found -" & str & "- to -" & unlock_codes(i)
				If unlock_codes(i) = str_Renamed Then
					unlocked(i) = 1
				End If
			Next i
		Loop 
		FileClose(1)
		
	End Sub
	
	Public Function do_unlock(ByVal i As Short) As Object
		FileOpen(1, My.Application.Info.DirectoryPath & "/achievements.txt", OpenMode.Append)
		PrintLine(1, unlock_codes(i))
		FileClose(1)
		'UPGRADE_WARNING: Couldn't resolve default property of object do_unlock. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		do_unlock = Chr(13) & "You have achieved: " & titles(i)
	End Function
	
	Public Function get_unlocked(ByVal i As Short) As Object
		get_unlocked = unlocked(i)
		
		If Campaign.scenario_selected > 0 And Me.Visible = False Then
			'UPGRADE_WARNING: Couldn't resolve default property of object get_unlocked. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			get_unlocked = 1
		End If
	End Function
End Class